<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小马儿 - 购物车</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="Shortcut Icon" href="img/horse.ico">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#CC6688',
                        secondary: '#FFD7E4',
                        neutral: '#F8F9FA',
                        dark: '#333333'
                    },
                    fontFamily: {
                        sans: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .bg-gradient-custom {
                background: linear-gradient(135deg, #CC6688 0%, #FF9AA2 100%);
            }
            .text-shadow {
                text-shadow: 0 2px 4px rgba(0,0,0,0.1);
            }
            .transition-custom {
                transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            }
            .scrollbar-hide::-webkit-scrollbar {
                display: none;
            }
            .scrollbar-hide {
                -ms-overflow-style: none;
                scrollbar-width: none;
            }
        }
    </style>
</head>
<body class="bg-neutral min-h-screen flex flex-col">
    <!-- 导航栏 -->
    <nav class="bg-white shadow-md sticky top-0 z-50 transition-all duration-300">
        <div class="container mx-auto px-4 py-3 flex justify-between items-center">
            <a href="index.html" class="flex items-center space-x-2">
                <i class="fa fa-horse text-primary text-2xl"></i>
                <span class="text-xl font-bold text-dark">小马儿</span>
            </a>
            <div class="hidden md:flex space-x-6">
                <a href="index.html" class="text-dark hover:text-primary transition-custom">首页</a>
                <a href="#" class="text-dark hover:text-primary transition-custom">产品</a>
                <a href="#" class="text-dark hover:text-primary transition-custom">服务</a>
                <a href="#" class="text-dark hover:text-primary transition-custom">关于我们</a>
            </div>
            <div class="flex items-center space-x-4">
                <a href="login.html" class="text-dark hover:text-primary transition-custom">登录</a>
                <a href="register.html" class="text-dark hover:text-primary transition-custom">注册</a>
                <a href="cart.html" class="relative text-dark hover:text-primary transition-custom">
                    <i class="fa fa-shopping-cart text-xl"></i>
                    <span class="absolute -top-2 -right-2 bg-primary text-white text-xs rounded-full h-5 w-5 flex items-center justify-center">3</span>
                </a>
                <button class="md:hidden text-dark">
                    <i class="fa fa-bars text-xl"></i>
                </button>
            </div>
        </div>
    </nav>

    <!-- 主内容区 -->
    <main class="flex-grow py-12 px-4">
        <div class="container mx-auto">
            <div class="mb-8">
                <h1 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold text-dark">我的购物车</h1>
                <div class="w-20 h-1 bg-primary mt-2"></div>
            </div>

            <div class="bg-white rounded-2xl shadow-lg overflow-hidden">
                <!-- 购物车为空状态 -->
                <!-- <div class="py-16 px-4 text-center">
                    <div class="text-6xl text-gray-300 mb-4">
                        <i class="fa fa-shopping-cart"></i>
                    </div>
                    <h3 class="text-xl font-medium text-gray-700 mb-2">购物车是空的</h3>
                    <p class="text-gray-500 mb-6">您还没有添加任何商品到购物车</p>
                    <a href="index.html" class="inline-block bg-primary hover:bg-primary/90 text-white px-6 py-3 rounded-lg shadow-md hover:shadow-lg transition-custom">
                        开始购物
                    </a>
                </div> -->

                <!-- 购物车有商品状态 -->
                <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
                    <!-- 商品列表 -->
                    <div class="lg:col-span-2 p-6">
                        <div class="border-b border-gray-200 pb-4 mb-4">
                            <h2 class="text-lg font-medium text-gray-800">已选商品</h2>
                        </div>

                        <!-- 商品项 1 -->
                        <div class="flex flex-col md:flex-row gap-4 p-4 mb-4 bg-neutral rounded-xl">
                            <div class="w-full md:w-24 h-24 rounded-lg overflow-hidden">
                                <img src="https://picsum.photos/id/26/200/200" alt="商品图片" class="w-full h-full object-cover">
                            </div>
                            <div class="flex-grow">
                                <div class="flex flex-col md:flex-row justify-between">
                                    <div>
                                        <h3 class="font-medium text-gray-800 mb-1">高级智能手表</h3>
                                        <p class="text-sm text-gray-500 mb-2">颜色: 黑色 | 尺寸: 42mm</p>
                                        <div class="flex items-center">
                                            <button class="w-8 h-8 flex items-center justify-center rounded border border-gray-300 text-gray-600 hover:bg-gray-100 transition-custom">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                            <input type="number" value="1" min="1" class="w-12 h-8 text-center border-y border-gray-300">
                                            <button class="w-8 h-8 flex items-center justify-center rounded border border-gray-300 text-gray-600 hover:bg-gray-100 transition-custom">
                                                <i class="fa fa-plus"></i>
                                            </button>
                                        </div>
                                    </div>
                                    <div class="mt-4 md:mt-0 text-right">
                                        <p class="font-medium text-gray-800">¥1,299.00</p>
                                        <button class="text-gray-400 hover:text-red-500 mt-2 transition-custom">
                                            <i class="fa fa-trash"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 商品项 2 -->
                        <div class="flex flex-col md:flex-row gap-4 p-4 mb-4 bg-neutral rounded-xl">
                            <div class="w-full md:w-24 h-24 rounded-lg overflow-hidden">
                                <img src="https://picsum.photos/id/96/200/200" alt="商品图片" class="w-full h-full object-cover">
                            </div>
                            <div class="flex-grow">
                                <div class="flex flex-col md:flex-row justify-between">
                                    <div>
                                        <h3 class="font-medium text-gray-800 mb-1">无线蓝牙耳机</h3>
                                        <p class="text-sm text-gray-500 mb-2">颜色: 白色 | 版本: 标准版</p>
                                        <div class="flex items-center">
                                            <button class="w-8 h-8 flex items-center justify-center rounded border border-gray-300 text-gray-600 hover:bg-gray-100 transition-custom">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                            <input type="number" value="2" min="1" class="w-12 h-8 text-center border-y border-gray-300">
                                            <button class="w-8 h-8 flex items-center justify-center rounded border border-gray-300 text-gray-600 hover:bg-gray-100 transition-custom">
                                                <i class="fa fa-plus"></i>
                                            </button>
                                        </div>
                                    </div>
                                    <div class="mt-4 md:mt-0 text-right">
                                        <p class="font-medium text-gray-800">¥598.00</p>
                                        <button class="text-gray-400 hover:text-red-500 mt-2 transition-custom">
                                            <i class="fa fa-trash"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 商品项 3 -->
                        <div class="flex flex-col md:flex-row gap-4 p-4 mb-4 bg-neutral rounded-xl">
                            <div class="w-full md:w-24 h-24 rounded-lg overflow-hidden">
                                <img src="https://picsum.photos/id/160/200/200" alt="商品图片" class="w-full h-full object-cover">
                            </div>
                            <div class="flex-grow">
                                <div class="flex flex-col md:flex-row justify-between">
                                    <div>
                                        <h3 class="font-medium text-gray-800 mb-1">智能手环</h3>
                                        <p class="text-sm text-gray-500 mb-2">颜色: 蓝色 | 功能: 心率监测</p>
                                        <div class="flex items-center">
                                            <button class="w-8 h-8 flex items-center justify-center rounded border border-gray-300 text-gray-600 hover:bg-gray-100 transition-custom">
                                                <i class="fa fa-minus"></i>
                                            </button>
                                            <input type="number" value="1" min="1" class="w-12 h-8 text-center border-y border-gray-300">
                                            <button class="w-8 h-8 flex items-center justify-center rounded border border-gray-300 text-gray-600 hover:bg-gray-100 transition-custom">
                                                <i class="fa fa-plus"></i>
                                            </button>
                                        </div>
                                    </div>
                                    <div class="mt-4 md:mt-0 text-right">
                                        <p class="font-medium text-gray-800">¥299.00</p>
                                        <button class="text-gray-400 hover:text-red-500 mt-2 transition-custom">
                                            <i class="fa fa-trash"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="flex justify-between items-center mt-8">
                            <a href="index.html" class="inline-flex items-center text-primary hover:text-primary/80 transition-custom">
                                <i class="fa fa-arrow-left mr-2"></i>
                                继续购物
                            </a>
                            <button class="text-red-500 hover:text-red-600 transition-custom">
                                清空购物车
                            </button>
                        </div>
                    </div>

                    <!-- 结算信息 -->
                    <div class="lg:col-span-1 bg-neutral p-6">
                        <div class="border-b border-gray-200 pb-4 mb-4">
                            <h2 class="text-lg font-medium text-gray-800">订单结算</h2>
                        </div>

                        <div class="space-y-4">
                            <div class="flex justify-between">
                                <span class="text-gray-600">商品总价</span>
                                <span class="text-gray-800">¥2,196.00</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-gray-600">运费</span>
                                <span class="text-gray-800">¥0.00</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-gray-600">优惠折扣</span>
                                <span class="text-red-500">-¥100.00</span>
                            </div>
                            <div class="border-t border-gray-200 pt-4 flex justify-between">
                                <span class="font-medium text-gray-800">订单总价</span>
                                <span class="font-bold text-lg text-primary">¥2,096.00</span>
                            </div>

                            <div class="mt-6">
                                <button class="w-full bg-primary hover:bg-primary/90 text-white font-medium py-3 px-4 rounded-lg shadow-md hover:shadow-lg transition-custom flex items-center justify-center">
                                    <span>立即结算</span>
                                    <i class="fa fa-arrow-right ml-2"></i>
                                </button>
                            </div>

                            <div class="mt-4">
                                <div class="flex items-center">
                                    <i class="fa fa-shield text-primary mr-2"></i>
                                    <span class="text-sm text-gray-600">安全支付保障</span>
                                </div>
                                <div class="flex items-center mt-2">
                                    <i class="fa fa-truck text-primary mr-2"></i>
                                    <span class="text-sm text-gray-600">全场满99元免运费</span>
                                </div>
                            </div>

                            <div class="mt-8">
                                <h3 class="font-medium text-gray-800 mb-3">优惠券</h3>
                                <div class="relative">
                                    <input type="text" placeholder="输入优惠码" class="w-full pl-4 pr-24 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-primary outline-none transition-custom">
                                    <button class="absolute right-1 top-1 bg-primary hover:bg-primary/90 text-white px-3 py-1 rounded transition-custom">
                                        应用
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 推荐商品 -->
            <div class="mt-12">
                <h2 class="text-xl font-bold text-dark mb-6">为您推荐</h2>
                <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
                    <!-- 推荐商品 1 -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden hover:shadow-lg transition-custom group">
                        <div class="h-48 overflow-hidden">
                            <img src="https://picsum.photos/id/96/300/300" alt="推荐商品" class="w-full h-full object-cover group-hover:scale-105 transition-custom duration-300">
                        </div>
                        <div class="p-4">
                            <h3 class="font-medium text-gray-800 mb-1">无线充电底座</h3>
                            <p class="text-sm text-gray-500 mb-2">兼容多款设备</p>
                            <div class="flex justify-between items-center">
                                <span class="font-medium text-primary">¥129.00</span>
                                <button class="w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center text-primary hover:bg-primary hover:text-white transition-custom">
                                    <i class="fa fa-shopping-cart"></i>
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- 推荐商品 2 -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden hover:shadow-lg transition-custom group">
                        <div class="h-48 overflow-hidden">
                            <img src="https://picsum.photos/id/160/300/300" alt="推荐商品" class="w-full h-full object-cover group-hover:scale-105 transition-custom duration-300">
                        </div>
                        <div class="p-4">
                            <h3 class="font-medium text-gray-800 mb-1">智能门锁</h3>
                            <p class="text-sm text-gray-500 mb-2">指纹识别，远程控制</p>
                            <div class="flex justify-between items-center">
                                <span class="font-medium text-primary">¥899.00</span>
                                <button class="w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center text-primary hover:bg-primary hover:text-white transition-custom">
                                    <i class="fa fa-shopping-cart"></i>
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- 推荐商品 3 -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden hover:shadow-lg transition-custom group">
                        <div class="h-48 overflow-hidden">
                            <img src="https://picsum.photos/id/119/300/300" alt="推荐商品" class="w-full h-full object-cover group-hover:scale-105 transition-custom duration-300">
                        </div>
                        <div class="p-4">
                            <h3 class="font-medium text-gray-800 mb-1">智能家居套装</h3>
                            <p class="text-sm text-gray-500 mb-2">一站式智能解决方案</p>
                            <div class="flex justify-between items-center">
                                <span class="font-medium text-primary">¥1,599.00</span>
                                <button class="w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center text-primary hover:bg-primary hover:text-white transition-custom">
                                    <i class="fa fa-shopping-cart"></i>
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- 推荐商品 4 -->
                    <div class="bg-white rounded-xl shadow-md overflow-hidden hover:shadow-lg transition-custom group">
                        <div class="h-48 overflow-hidden">
                            <img src="https://picsum.photos/id/26/300/300" alt="推荐商品" class="w-full h-full object-cover group-hover:scale-105 transition-custom duration-300">
                        </div>
                        <div class="p-4">
                            <h3 class="font-medium text-gray-800 mb-1">智能音箱</h3>
                            <p class="text-sm text-gray-500 mb-2">语音控制，多功能助手</p>
                            <div class="flex justify-between items-center">
                                <span class="font-medium text-primary">¥299.00</span>
                                <button class="w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center text-primary hover:bg-primary hover:text-white transition-custom">
                                    <i class="fa fa-shopping-cart"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- 页脚 -->
    <footer class="bg-dark text-white py-10 mt-12">
        <div class="container mx-auto px-4">
            <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
                <div>
                    <div class="flex items-center space-x-2 mb-4">
                        <i class="fa fa-horse text-primary text-2xl"></i>
                        <span class="text-xl font-bold">小马儿</span>
                    </div>
                    <p class="text-gray-400">小马儿提供最优质的服务，让您的生活更加便捷。</p>
                    <div class="flex space-x-4 mt-4">
                        <a href="#" class="text-gray-400 hover:text-primary transition-custom">
                            <i class="fa fa-facebook"></i>
                        </a>
                        <a href="#" class="text-gray-400 hover:text-primary transition-custom">
                            <i class="fa fa-twitter"></i>
                        </a>
                        <a href="#" class="text-gray-400 hover:text-primary transition-custom">
                            <i class="fa fa-instagram"></i>
                        </a>
                    </div>
                </div>
                
                <div>
                    <h3 class="text-lg font-semibold mb-4">快速链接</h3>
                    <ul class="space-y-2">
                        <li><a href="#" class="text-gray-400 hover:text-primary transition-custom">首页</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-primary transition-custom">产品</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-primary transition-custom">服务</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-primary transition-custom">关于我们</a></li>
                    </ul>
                </div>
                
                <div>
                    <h3 class="text-lg font-semibold mb-4">联系我们</h3>
                    <ul class="space-y-2">
                        <li class="flex items-start space-x-3">
                            <i class="fa fa-map-marker text-primary mt-1"></i>
                            <span class="text-gray-400">北京市朝阳区建国路88号</span>
                        </li>
                        <li class="flex items-start space-x-3">
                            <i class="fa fa-phone text-primary mt-1"></i>
                            <span class="text-gray-400">400-123-4567</span>
                        </li>
                        <li class="flex items-start space-x-3">
                            <i class="fa fa-envelope text-primary mt-1"></i>
                            <span class="text-gray-400">contact@xiaomaer.com</span>
                        </li>
                    </ul>
                </div>
                
                <div>
                    <h3 class="text-lg font-semibold mb-4">订阅我们</h3>
                    <p class="text-gray-400 mb-4">订阅我们的通讯，获取最新的产品和服务信息。</p>
                    <form class="flex">
                        <input type="email" placeholder="您的邮箱地址" class="px-4 py-2 rounded-l-lg focus:outline-none focus:ring-2 focus:ring-primary w-full">
                        <button type="submit" class="bg-primary hover:bg-primary/90 text-white px-4 py-2 rounded-r-lg transition-custom">
                            <i class="fa fa-paper-plane"></i>
                        </button>
                    </form>
                </div>
            </div>
            
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500">
                <p>© 2025 小马儿 All Rights Reserved.</p>
            </div>
        </div>
    </footer>

    <script>
        // 数量增减按钮
        document.querySelectorAll('.fa-minus').forEach(btn => {
            btn.parentElement.addEventListener('click', function() {
                const input = this.parentElement.querySelector('input');
                if (parseInt(input.value) > 1) {
                    input.value = parseInt(input.value) - 1;
                    updateCart();
                }
            });
        });

        document.querySelectorAll('.fa-plus').forEach(btn => {
            btn.parentElement.addEventListener('click', function() {
                const input = this.parentElement.querySelector('input');
                input.value = parseInt(input.value) + 1;
                updateCart();
            });
        });

        // 移除商品
        document.querySelectorAll('.fa-trash').forEach(btn => {
            btn.parentElement.addEventListener('click', function() {
                const product = this.closest('.flex-col, .flex-row');
                product.classList.add('opacity-0');
                setTimeout(() => {
                    product.remove();
                    updateCart();
                    checkCartEmpty();
                }, 300);
            });
        });

        // 清空购物车
        document.querySelector('.text-red-500').addEventListener('click', function() {
            const products = document.querySelectorAll('.flex-col.md\\:flex-row');
            products.forEach(product => {
                product.classList.add('opacity-0');
            });
            setTimeout(() => {
                products.forEach(product => product.remove());
                checkCartEmpty();
            }, 300);
        });

        // 检查购物车是否为空
        function checkCartEmpty() {
            const cartItems = document.querySelectorAll('.flex-col.md\\:flex-row');
            const cartContainer = document.querySelector('.grid.grid-cols-1.lg\\:grid-cols-3');
            const emptyState = document.createElement('div');
            emptyState.className = 'py-16 px-4 text-center';
            emptyState.innerHTML = `
                <div class="text-6xl text-gray-300 mb-4">
                    <i class="fa fa-shopping-cart"></i>
                </div>
                <h3 class="text-xl font-medium text-gray-700 mb-2">购物车是空的</h3>
                <p class="text-gray-500 mb-6">您还没有添加任何商品到购物车</p>
                <a href="index.html" class="inline-block bg-primary hover:bg-primary/90 text-white px-6 py-3 rounded-lg shadow-md hover:shadow-lg transition-custom">
                    开始购物
                </a>
            `;
            
            if (cartItems.length === 0) {
                cartContainer.innerHTML = '';
                cartContainer.appendChild(emptyState);
            }
        }

        // 更新购物车总价（示例逻辑）
        function updateCart() {
            // 这里只是示例，实际项目中需要根据商品价格和数量计算总价
            const prices = [1299, 598, 299];
            let total = 0;
            
            const quantities = document.querySelectorAll('input[type="number"]');
            quantities.forEach((qty, index) => {
                total += parseInt(qty.value) * prices[index];
            });
            
            // 更新显示
            document.querySelector('.text-primary.font-bold').textContent = `¥${total}.00`;
            document.querySelector('.text-gray-800:last-of-type').textContent = `¥${total}.00`;
        }

        // 导航栏滚动效果
        window.addEventListener('scroll', function() {
            const nav = document.querySelector('nav');
            if (window.scrollY > 10) {
                nav.classList.add('py-2', 'shadow-lg');
                nav.classList.remove('py-3', 'shadow-md');
            } else {
                nav.classList.add('py-3', 'shadow-md');
                nav.classList.remove('py-2', 'shadow-lg');
            }
        });
    </script>
</body>
</html>    